#include<iostream>

using namespace std;

//greater_than_zero
//input: an array and the size
//output: the amount of members greater than zero
int greater_than_zero(int data[], int size)
{
	int count; // counter for the odd numbers.
	int i; // looper.
	count = 0;
	for(i=0;i<size;i++)
		if(data[i] > 0) count++;
	return count;
}
//copy_odd
//input: an array, it size and a output array
//output: the size of the second array
int copy_odd(int a[], int size_a, int b[])
{
	int i; // looper
	int size_b=0; // size for the second array
	for(i=0;i<size_a;i++)
		if(a[i]%2 != 0)
		{
			b[size_b] = a[i];
			size_b++;
		}
	return size_b;

}
//remove_odd
//input: an array and it size
//output: the size of the rearranged array without the odd numbers
int remove_odd(int a[], int size)
{
	int i,j; // loopers
	int count; // counts the removed digits
	count=0;
	for(i=0;i<size;i++)
	{
		if(a[i]%2!=0)
		{
			for(j=i;j<size - 1;j++)
				a[j] = a[j+1];
			count++;
		}

	}
	return size - count;
}
//split_parity
//input: an array and it size
//output: changes the array order to group of odds and non odds
void split_parity(int a[], int size)
{
	int i; // looper
	int left, right; //index for the odds and non odds
	int swap; //temporary variable to shift the entry around.
	i = 0;
	left = 0;
	right = size - 1;
	while(left<right)
	{
		if(a[i]%2 == 0)
		{
			swap = a[left];
			a[left] = a[i];
			a[i] = swap;
			left++;
		}
		else
		{
			swap=a[right];
			a[right] = a[i];
			a[i] = swap;
			right--;
		}
		i++;

	}

}
//1. prompt for an array
//2. move the numbers around per their odditity.
int main()
{
	int i; // looper
	int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; //the testing array
	split_parity(data, 9);
	for(i=0;i<9;i++)
		cout << data[i] << '\t';
	cout << endl;
}
//output
//2	4	6	9	3	5	8	7	1	
